<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script src="<c:url value='/js/search_valid.js'/>"></script>
<div class="page-header">
	<h3 style="margin-top: auto">用户列表</h3>
	<form class="form-search"
		action="<%=request.getContextPath()%>/user/search" method="POST"
		onsubmit="return valid();">
		<div class="input-append">
			<input type="text" class="span1 search-query" id="searchText"
				name="searchText" style="margin-left: 20px; width: 400px">
			<button type="submit" class="btn">
				<i class="icon-search"></i>&nbsp;搜索用户
			</button>
		</div>
	</form>
</div>
<div class="row-fluid">
	<div>
		<c:choose>
			<c:when test="${!empty bean}">
				<table class="table table-hover">
					<thead>
						<tr>
							<th width="10%">编号</th>
							<th width="20%">用户名</th>
							<th width="20%">真实姓名</th>
							<th width="20%">工号</th>
							<th width="30%">操作</th>
						</tr>
					</thead>
					<tbody>
					<c:forEach items="${bean.getList()}" var="list" varStatus="s">
						<tr>
							<td><c:out value="${s.count}" /></td>
							<td><c:out value="${list.username}" /></td>
							<td><c:out value="${list.realname}" /></td>
							<td><c:out value="${list.staffNum}" /></td>
							<td><button class="btn"
									onclick="window.location.href='<%=request.getContextPath()%>/user/${list.id}';"><i class="icon-search"></i>&nbsp;详细信息</button></td>
						</tr>
					</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="8">
								<div class="pagination pagination-centered">
									<c:set value="${bean.getCurrentPage()}" var="currentPNum"
										scope="page"></c:set>
									<c:set value="${bean.getTotalPage()}" var="totalSize"
										scope="page"></c:set>
									<ul>
										<c:choose>
											<c:when test="${currentPNum == 1}">
												<li class="disabled"><a href="javascript:void(0);">&laquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum-1}">&laquo;</a></li>
											</c:otherwise>
										</c:choose>
										<li class="active"><a href="javascript:void(0);"><c:out
													value="${currentPNum}" /></a></li>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum+1}"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+2 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum+2}"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+3 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum+3}"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+4 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum+4}"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);">&raquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/user/list?pageNum=${currentPNum+1}">&raquo;</a></li>
											</c:otherwise>
										</c:choose>
									</ul>
								</div>
							<td>
					</tfoot>
				</table>
			</c:when>
			<c:otherwise>
				<c:if test="${flag != 1}">
				<h3 style="margin-top: auto">数据库暂无相关用户信息</h3>
				</c:if>
			</c:otherwise>
		</c:choose>
	</div>
</div>